
#ifndef NODE_H_

#define NODE_H_

#include "common.h"
#include "eventhandler.h"
#include "object.h"

class Packet;
class Event;

class Node : public EventHandler, public Object{
	public:
		Node( node_id_t n_id )
			: node_id_(n_id)
			, is_online_(false)
		{}

		virtual void onJoining();
		virtual void onDeparture();
		virtual void onReceived( Packet *packet ){}

		bool isOnline() const { return is_online_; }
		bool send( node_id_t dst_id, Packet *packet );
		node_id_t getNodeID() const { return node_id_; }

		//implementation of EventHandler
		virtual void onEvent( Event *event );
		virtual void onTimer( Timer *timer );

	protected:
		void setOnline(bool s=true) { is_online_=s; }
	protected:
		node_id_t node_id_;
		bool      is_online_;
};

#endif /* NODE_H_ */

